/*
 * LoaderOBJ.h
 *
 *  Created on: 09.07.2011
 *      Author: alki
 */

#include "Loader.h"

#ifdef LOADEROBJ_TAGS
#undef LOADEROBJ_TAGS

enum TAG { mtllib,o,NUL,v,usemtl,f };
enum MATERIALTAG { newmtl,Ka,Kd,Ks,Ke };

class SURFACE {
public:
	vector<unsigned int> vertex;
	vector<float> u,v;
	int material;
	int tex;
};

#endif

#ifndef LOADEROBJ_H_
#define LOADEROBJ_H_

#include <iostream>
#include <fstream>

class SURFACE;

class LoaderOBJ : public Loader {
public:
	LoaderOBJ();
	virtual ~LoaderOBJ();

	void LoadFile(string filename,vector<Objekt> &objekte,MaterialManager &matman);

private:
	ifstream m_file;

	int ReadTagLine(string &line);

	void ReadMaterial(const string &line,const string &filename);

	vector<Objekt> m_objekte;
	vector<Material> m_materialien;
	vector<string> m_materialnamen;
	vector<Textur> m_textur;

	vector<Vektor> m_vertices;
	vector<SURFACE> m_surfaces;

	MaterialManager *m_matman;
	void CreateObject(Objekt *obj,unsigned int verts);
};

#endif /* LOADEROBJ_H_ */
